<?php

/* * 
 * 资讯
 */
namespace Common\Model;
use Think\Model;
class GiftOrderModel extends BaseModel {

    public function queryForList($page=null, $map=null) {
        $list = $this->alias("go")
            ->join("left join __ORDER__ o on o.order_id = go.order_id")
            ->join("left join __ROUND__ r on r.round_id = o.round_id")
            ->join("left join __PRODUCT__ p on p.product_id = r.product_id")
            ->join("left join __CUSTOMER__ c on c.customer_id = o.customer_id")
            ->where(getWhereSqlByMap($map))
            ->order("go.create_time desc")
            ->limit($page->firstRow . ',' . $page->listRows)
            ->field("go.gift_order_id,go.name,go.order_id,p.product_name,go.status,r.round_index,go.address,go.mobile,c.nickname")
            ->select();

        return $list;

    }

    public function getListCount($map = null) {

        $count = $this->alias("go")
            ->join("left join __ORDER__ o on o.order_id = go.order_id")
            ->join("left join __ROUND__ r on r.round_id = o.round_id")
            ->join("left join __PRODUCT__ p on p.product_id = r.product_id")
            ->join("left join __CUSTOMER__ c on c.customer_id = o.customer_id")
            ->where(getWhereSqlByMap($map))
            ->count();

        return $count;
    }

}

